<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>基础设置</el-breadcrumb-item>
      <el-breadcrumb-item>门店信息</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card>
      <div class="form_title">
        <h5>门店信息</h5>
      </div>
      <!-- 门店表单 -->
      <el-form ref="form" :model="form" label-width="90px">
        <el-form-item label="门店名称：">
          <el-col :span="11">
            <el-input v-model="form.name"></el-input>
          </el-col>
        </el-form-item>
        <!-- <el-form-item label="门店logo：">
          <el-upload
            class="upload-demo"
            action="https://jsonplaceholder.typicode.com/posts/"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :file-list="fileList"
            list-type="picture"
            limit = 1
          >
            <el-button size="small" type="primary">点击上传</el-button>
            <span slot="tip" class="el-upload__tip">
              只能上传jpg/png文件
            </span>
          </el-upload>
        </el-form-item> -->
        <el-form-item label="门店电话：">
          <el-col :span="11">
            <el-input v-model="form.phone"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="门店地址：">
          <el-col :span="11">
            <el-input v-model="form.address"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item class="formbutton">
          <el-button
            class="formsubmit"
            type="primary"
            @click="onSubmit"
            :disabled="disabled"
            >提交</el-button
          >
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelPosition: "right",
      form: {},
    };
  },
  methods: {
    async getStore() {
      const { data: res } = await this.$http.get(
        "store/listStore"
      );
      console.log(res);
      if (res.code !== 200) {
        return this.$message.error(res.massage);
      }
      this.form = res.data.stores[0];
    },
    //提交调用相应的接口
    async onSubmit() {
      console.log(this.form)
      const { data: res } = await this.$http.post(
        "store/updateStore",
        this.form
      );
      if (res.code !== 200) {
        return this.$message.error(res.massage);
      }
      this.$message.success(res.massage);
      console.log(res);
      this.getStore();
      // console.log("submit!");
    },
  },
  created() {
    //页面生成时需要获取门店信息的接口
    this.getStore();
  },
};
</script>

<style lang="less" scoped>
.form_title {
  height: 40px;
  text-align: left;
  line-height: 0px;
  letter-spacing: 1px;
  border-left: rgba(64, 158, 255, 0.781) solid 3px;
  box-shadow: 0 3px 8px #ddd;
  padding-left: 10px;
  margin-top: 0px;
  overflow: hidden;
}

.el-form {
  width: 800px;
  margin: 50px auto;
  text-align: center;
  padding-left: 350px;
}
.formbutton {
  position: relative;
}
.formbutton .formsubmit {
  position: absolute;
  left: 80px;
}
</style>
